package cn.qiao.dynamicProxy.service;

import cn.qiao.dynamicProxy.LogHandlerProxy;
import cn.qiao.dynamicProxy.service.impl.UserServiceImpl;

import java.lang.reflect.Proxy;

/**
 * desc:
 *
 * @author qiao
 * @date 2023年07月19日 22:29
 */
public class Demo {

    public static void main(String[] args) {

        UserService userService = new UserServiceImpl();

        LogHandlerProxy logHandlerProxy = new LogHandlerProxy(userService);

        UserService o = (UserService)Proxy.newProxyInstance(
                userService.getClass().getClassLoader(),
                userService.getClass().getInterfaces(),
                logHandlerProxy
        );

        int count = o.getCount();
        System.out.println(count);
    }

}
